﻿#pragma once

namespace df
{
	void Exception::ExceptionLog(Exception & seh)
	{

		String msg;

		msg << tcc_("Exception:\r\n") << seh.message_ << tcc_("\r\n");

#if _DEBUG || DF_LOG_FILE_LINE==1
		if (seh.fileLine_.length_ > 0)
			msg << seh.fileLine_ << tcc_("\r\n");
#endif

		if (seh.code_ > 0)
		{
			msg << tcc_("ErrCode:(") << seh.code_ << tcc_(") ");
			GetErrorString(seh.code_, msg);
		}

		WriteLog(msg);
	}

	void Exception::ExceptionLog(const df::CCa & str)
	{
#ifdef UNICODE
		WriteLog(tcc_("runtime Exception:\r\n") + df::code::AnsiToWide(str));
#else
		WriteLog(tcc_("runtime Exception:\r\n") + str);
#endif
		COUT(tcc_("-------runtime Exception------\n") << str.char_);
	
	}

	void Exception::ExceptionLog(const df::CCw & str)
	{
#ifdef UNICODE
		WriteLog(tcc_("runtime Exception:\r\n") + str);
#else
#	ifdef WIN32
		WriteLog(tcc_("runtime Exception:\r\n") + df::code::WideToAnsi(str));
#	endif // WIN32
#endif
		COUT(tcc_("-------Exception------\n") << str.char_);
	}
}